package com.ncmmall.api.apis.mall;

import com.ncmmall.api.apis.service.Result;
import com.ncmmall.domain.business.aboutus.AboutUs;
import com.ncmmall.querychannel.service.QueryChannelService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Collections;

/**
 * 关于我们
 *
 * @author likaikai
 * @date 2019-07-14 18:10
 */
@RestController
public class AboutUsApi {

    @Autowired
    private QueryChannelService queryChannelService;

    private final Logger logger = LoggerFactory.getLogger(AboutUsApi.class);

    /**
     * 关于我们
     */
    @GetMapping("/aboutUs")
    public Result aboutUs() {
        Result result = new Result();
        try {
            AboutUs aboutUs = queryChannelService.queryOneEntity("select * from mall_about_us", Collections.emptyMap(), AboutUs.class);
            return result.ok().inject(aboutUs);
        } catch (Exception e) {
            logger.error("[获取关于我们异常]", e);
            return result.fail().setMsg("网络请求异常");
        }
    }

}
